$(function () {
    $("#jqGrid").jqGrid({
        url: '../log/queryAll',
        datatype: "json",
        colModel: [
            {label: 'id', name: 'id', key: true, hidden: true},
            /*{label: '用户名', name: 'username', width: 50},*/
            {label: '用户名', name: 'user.username', width: 50},
            {label: '内容', name: 'content', width: 70},
            {label: '请求方法', name: 'method', width: 150},
          /*  {label: '请求参数', name: 'params', width: 80},*/
            {label: 'IP地址', name: 'userIp', width: 70},
            {
                label: '创建时间', name: 'createTime', width: 90, formatter: function (value) {
                return transDate(value);
            }
            },
            {
                label: '耗时', name: 'spendTime', width: 90, formatter: function (value) {
                return transDate(value);
            }
            }
        ],
        viewrecords: true,
        height: 385,
        rowNum: 10,
        rowList: [10, 30, 50],
        rownumbers: true,
        rownumWidth: 25,
        autowidth: true,
        multiselect: false,
        pager: "#jqGridPager",
        jsonReader: {
            root: "page.list",
            page: "page.pageNum",
            total: "page.pages",
            records: "page.total"
        },
        prmNames: {
            page: "page",
            rows: "limit",
            order: "order"
        },
        gridComplete: function () {
            //隐藏grid底部滚动条
            $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
        }
    });
});

var vm = new Vue({
    el: '#rrapp',
    data: {
        q: {
            key: null
        },
        isLogin: []
    },
    methods: {
        query: function () {
            vm.reload();
        },
        reload: function (event) {
            var page = $("#jqGrid").jqGrid('getGridParam', 'page');

            $("#jqGrid").jqGrid('setGridParam', {
                postData: {'key': vm.q.key, 'operation': vm.isLogin.toLocaleString()},
                page: page
            }).trigger("reloadGrid");
        }
    }
});